package com.lagou.demo.controller;

import com.lagou.demo.service.IDemoService;
import com.lagou.edu.mvcframework.annotations.LagouAutowired;
import com.lagou.edu.mvcframework.annotations.LagouController;
import com.lagou.edu.mvcframework.annotations.LagouRequestMapping;
import com.lagou.edu.mvcframework.annotations.LagouSecurity;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@LagouController
@LagouRequestMapping("/demo")
public class DemoController {


    @LagouAutowired
    private IDemoService demoService;


    /**
     * URL: /demo/query?name=lisi
     * @param request
     * @param response
     * @param name
     * @return
     */
    @LagouRequestMapping("/handle01")
    @LagouSecurity({"zhangsan", "wangwu"})
    public void handle1(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        response.getWriter().write(demoService.get(name));
    }

    @LagouRequestMapping("/handle02")
    @LagouSecurity({"lisi", "zhaoliu"})
    public void handle2(HttpServletRequest request, HttpServletResponse response,String name) throws IOException {
        response.getWriter().write(demoService.get(name));
    }
}
